package com.hirain.proxyjava;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created by caicf on 2016/8/31.
 */
public class ProxyHandler implements InvocationHandler {

    private Object object;

    public ProxyHandler(Object object) {
        this.object = object;
    }

    /**
     *
     * @param proxy    被代理对象
     * @param method   被代理对象的方法
     * @param args     方法参数
     * @return  Object  方法的返回值
     * @throws Throwable
     */
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("before invoke");
        return method.invoke(object,args);
    }
}
